import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router';
import Home from '@/view/Home/Home.vue';
const routes: RouteRecordRaw[] = [
  {
    path: "/",
    component: Home,
    children: [
      {
        path: "/",
        component: () => import("@/view/Home/index.vue")
      },
      {
        path: "/answers",
        component: () => import("@/view/Answers/index.vue"),
      },
      {
        path: "/answers/:id/details",
        component: () => import("@/view/answersDetails/index.vue"),
      },
      {
        path: "/how/question",
        component: () => import("@/view/howQuestion/index.vue"),
      },
      {
        path: "/special/column",
        component: () => import("@/view/specialColumn/index.vue"),
      },
      {
        path: "/special/:id/details",
        component: () => import("@/view/specialDetails/index.vue"),
      },
      {
        path: "/course",
        component: () => import("@/view/course/index.vue"),
      },
      {
        path: "/activity",
        component: () => import("@/view/activity/index.vue"),
      }
    ],
  },
  {
    path: "/login",
    component: () => import("@/view/Login/index.vue")
  },
  {
    path: "/:any(.*)",
    component: () => import("@/view/404/404.vue")
  },
  {
    path: "/add/problem",
    component: () => import('@/view/addProblem/index.vue')
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes,
  scrollBehavior(_to, _from, _savedPosition) {
    return {
      top: 0,
    }
  }
})


router.beforeEach((_to, _from, next) => {
  next();
})

export default router;